<!--
  // Creation History
  // --------------------------------------------------------------
  //	Company:			HTHK
  //	NAME:				TimeSheetSearch.jsp
  //	TITLE:				TimeSheet Search
  //	FUNCTION:			Search TimeSheet by selecting some conditions.
  //	BY:					Jet Tao
  //	DATE:				10/12/2003
  // UPDATE BY:			Beyes Xia
  //	UPDATE DATE:			2004-1-12 17:39
  // LAST UPDATE DATE:		2004-1-12 17:40
  // --------------------------------------------------------------
-->
<%@ include file="../tssheader.jsp" %>
<%@ page import="tss.timesheet.*" %>
<%@ page import="tss.options.*" %>
<SCRIPT Language="Javascript" SRC="<%=contextPath%>/tss/timesheet/Calendar1-821.js"></script>

<%

%>

<script language="JavaScript1.1">
<!--
function formValidation()
{
    if (fm.staff_name_option.value==null||fm.staff_name_option.value.length==0) 
	{
		alert("Please input Staff Name.");
		return false;
	}
    if (!checkDate(fm.selected_date)) 
	{
		return false;
	}
    
	return true;
}

function tss_calendar()
{
   var today = new Date();
   show_calendar('fm.selected_date', today.getMonth(), today.getYear(), 'YYYY-MM-DD');
}
function init()
{
   var today = new Date();
   month=(today.getMonth()+1>9)?(today.getMonth()+1):"0"+(today.getMonth()+1);
   date=(today.getDate()>9)?today.getDate():("0"+today.getDate());
   fm.selected_date.value=today.getYear()+"-"+month+"-"+date;
}
 function checkDate(object) {
    var obj=object;
    var d = obj.value;
    if (obj.value==null||obj.value.length==0) 
	{
		alert("Please input correct date with format as YYYY-MM-DD.");
		return false;
	}
    if (obj.value!=null && obj.value.length!=10) 
	{
       alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }
//    if (chLen(obj," date field (YYYY-MM-DD) ",10)==false)
//       return false;
    if (d.substring(4,5)!="-" || d.substring(7,8)!="-") {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }
    var day = d.substring(8,10);
    var month = d.substring(5,7);
    var year = d.substring(0,4);
    if (day==null || isNaN(day)) {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }
    if (month==null || isNaN(month)) {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }
    if (day==null || isNaN(day)) {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }
    if (day < 1 || day > 31) {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }

    if (month < 1 || month > 12) {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }

    if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
    }

    if (month == 2) {
        var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
        if (day > 29 || (day==29 && !isleap)) {
		alert("Please input correct date with format as YYYY-MM-DD.");
       return false;
        }
    }
    return true;
 }

-->

</script>

<body onload='init()'>
<h2>Time Sheet Search</h2>
<%
//****** Add By Beyes Xia
	StaffOptions staffProjectOptions=new StaffOptions();
	String staff_no = session.getAttribute("staffNameDfuValue")==null?"":(String)session.getAttribute("staffNameDfuValue");
//******
%>
<form id=fm method=post action='<%=contextPath%>/servlet/tss.timesheet.TimeSheetSearch' >
<table cols=4 >
<!-- Update By Beyes Xia -->
<tr>
  <td>Staff Name</td>
  <td>
  <select name=staff_name_option>
  <%=staffProjectOptions.getOptions(staff_no,false)%>
  </select>
  *
  </td>
</tr>
<!-- ------------------- -->
<tr>
  <td>Select Date</td>
  <td><input type=text name='selected_date' maxlength=10  ALIGN='LEFT' onBlur='checkDate(this)'>
      <input type=button name=but_cal onClick="tss_calendar();" value='...'>(YYYY-MM-DD)*</td>
</tr>

</table>
<br>
<hr>
<p>
  <INPUT type=button value=Search onclick='search()' >
  <INPUT type=reset  value=Cancel >
</p>
</form>
<%@ include file="../tssfooter.jsp" %>
</body>
</html>


